package com.ebt.m.commons.buscomponent.thirtylogin.qq;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;

import com.ebt.m.commons.buscomponent.thirtylogin.ShareBlock;
import com.tencent.connect.share.QQShare;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.Tencent;

/**
 * Created by andy.wang on 2016/10/18.
 */

public class QQShareManager {

    public static final int QZONE_SHARE_TYPE = 0;

    private String mAppId;

    private Tencent mTencent;

    private QQShare mQQShare;

    private Context mContext;


    public QQShareManager(Context context) {
        mAppId = ShareBlock.getInstance().getQQAppId();
        mContext = context;
        if (!TextUtils.isEmpty(mAppId)) {
            mTencent = Tencent.createInstance(mAppId, context);
            mQQShare = new QQShare(context, mTencent.getQQToken());
        }
    }

    public void shareToQQ(Bundle param, IUiListener uiListener) {
        if (mQQShare != null) {
            mQQShare.shareToQQ((Activity) mContext, param, uiListener);
        }
    }

    public void shareToQZone(Bundle param, IUiListener uiListener) {
        if (mTencent != null) {
            mTencent.shareToQzone((Activity) mContext, param, uiListener);
        }
    }

    public void onActivityResultData(int requestCode, int resultCode, Intent data, IUiListener listener){
        if (listener != null) {
            Tencent.onActivityResultData(requestCode, resultCode, data, listener);
        }
    }
}
